@extends('default.layouts.adminPublic')
@section('title', '资讯分类列表')

@section('content')
        <!--导航开始-->
<div class="crumb_warp">
    <i class="fa fa-home"></i> <a href="{{url('admin')}}">首页</a> &raquo; 资讯管理
</div>
<!--导航结束-->

<!--列表开始-->

<div class="result_wrap">
    <div class="result_title">
        <h3>资讯分类列表</h3>
        @include('flash::message')
    </div>
    <!--快捷导航 开始-->
    <div class="result_content">
        <div class="short_wrap">
            <a href="{{ url('admin/newscategory/create?type=firstclass') }}"><i class="fa fa-plus"></i>添加一级类</a>
            <a href="{{ url('admin/newscategory/create?type=secondclass') }}"><i class="fa fa-plus"></i>添加二级类</a>
            <em>{{ session('message') }}</em>
        </div>
    </div>
    <!--快捷导航 结束-->
</div>


<div class="result_wrap">
    <div class="result_content">
        <ul class="list_tab make">
            <li class="title border_buttom">
                <span class="first">序号</span>
                <span class="category-third ">分类名称</span>
                <span class="third">分类标识</span>
                <span class="four">分类等级</span>
                <span class="category-five">操作</span>
            </li>
            @if(count($CategoryList) > 0)
                @foreach($CategoryList as $k => $v)
                    <li class="saith_bg">
                        <span class="first">{{  $v->descid }}</span>
                        <span class="category-third">{{ $v->defectsname  }}</span>
                        <span class="third">{{ $v->new_sign  }}</span>
                        <span class="four">父级</span>
                    <span class="category-five">
                    <a href="{{ url('admin/newscategory/'.$v['id'].'/edit/?level='.$v['level']) }}">修改分类</a>
                    <a onclick="delClass('{{$v->id}}','{{$v->level}}')">删除分类</a>
                    </span>
                    </li>
                    @if(count($v['twoCategory']) > 0)
                        @foreach($v['twoCategory'] as $kk => $vv)
                            <li class="saith_bg double_b">
                                <span class="first">{{ $vv->descid }}</span>
                                <span class="category-third">{{ $v->html  }}{{ $vv->defectsname }}</span>
                                <span class="third">{{ $vv->new_sign }}</span>
                                <span class="four">子级</span>
                                <span class="category-five">
                                <a href="{{ url('admin/newscategory/'.$vv['id'].'/edit/?level='.$vv['level']) }}">修改分类</a>
                                <a onclick="delClass('{{$vv->id}}','{{$vv->level}}')">删除分类</a>
                                </span>
                            </li>
                        @endforeach
                    @endif
                @endforeach
            @endif
        </ul>
    </div>
</div>
<div class="page_list">
    {{--<div>{!! $news->links() !!}</div>--}}
</div>
<!--列表结束-->

<script>
    //删除资讯
    function delClass(id, level){
        layer.confirm('您确定要删除这个分类吗？', {
            btn: ['确定', '取消'] //按钮
        }, function(){
            $.post("{{url('admin/newscategory/')}}/" + id, {
                '_method': 'delete',
                'level': level,
                '_token': "{{csrf_token()}}"
            }, function(data){
                if(data.status == 0){
                    layer.msg(data.msg, {icon: 6, time: 1500});
                    location = '/admin/newscategory';
                }else{
                    layer.msg(data.msg, {icon: 5, time: 1500});
                }
            });
        });
    }
</script>
@endsection